package com.inspur.security.cbb3.kms.keymanager.containersecret.repository;

import com.inspur.security.cbb3.kms.keymanager.containersecret.po.ContainerSecretBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * 容器-密钥关联关系表
 * @author lijunchang
 */
public interface ContainerSecretRepository extends JpaRepository<ContainerSecretBean, String>, JpaSpecificationExecutor<ContainerSecretBean> {
    /**
     * 根据containerId列表查找关联密钥
     * @param containerIds  容器主键列表
     * @return  关联关系对象集合
     */
    List<ContainerSecretBean> findByContainerIdIn(List<String> containerIds);

    /**
     * 根据containerId查找关联密钥
     * @param containerId  容器主键
     * @return  关联关系对象集合
     */
    List<ContainerSecretBean> findByContainerId(String containerId);

    /**
     * 根据containerId查找关联关系
     * @param secretId  密钥主键
     * @return  关联关系对象集合
     */
    List<ContainerSecretBean> findBySecretId(String secretId);
    /**
     * 根据containerId、secretId查找关联密钥
     * @param containerId   容器主键
     * @param secretId      密钥主键
     * @return  关联关系对象集合
     */
    List<ContainerSecretBean> findByContainerIdAndSecretIdOrderByCreatedTimeDesc(String containerId,String secretId);
}
